home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / strdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  305 b   |  20 lines

  1. /*
  2.  * strdup: return a duplicate of a string
  3.  * Written by Eric R. Smith and placed in the public domain.
  4.  */
  5.  
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <memory.h>
  9.  
  10. char *strdup(s)
  11. _CONST char *s;
  12. {
  13.     char *dup;
  14.     
  15.     dup = malloc(strlen(s)+1);
  16.     if (dup)
  17.     strcpy(dup, s);
  18.     return dup;
  19. }
  20.